package com.lfg.leetcode.leetcode0;

/**
 * 给定一个字符串 s，找到 s 中最长的回文子串
 */
public class No9IsPalindrome {

    public static void main(String[] args) {
        System.out.println(isPalindrome(1234554321));
//        System.out.println(convert("0123456789012345678901234567890", 4));
//        System.out.println(convert("PAYPALISHIRING", 4));
    }


    public static boolean isPalindrome(int x) {
        if (x < 0) {
            return false;
        }
        if (x < 10) {
            return true;
        }
        if (x % 10 == 0) {
            return false;
        }
        int r = 0;
        while (x > r) {
            r = r * 10 + x % 10;
            x = x / 10;
        }
        if (r == x || x == r / 10) {
            return true;
        }

        return false;
    }
}
